<template>
	<!-- <van-cell
	  is-link
	  title="单元格"
	  link-type="navigateTo"
	  url="../orderForm/orderForm"
	/> -->
	<view class="my-container" id="longing">
		<!-- 用户未登录 -->
		<block v-if="!openid">
			<image class="avatar avatar-img" src="" mode="scaleToFill" />


			<button class="login-btn" type="primary" @click="wxlogin">
				微信用户一键登录
			</button>
			<view class="login-desc">登录后可同步数据</view>
		</block>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				info: [],
				token: null
			}
		},
		methods: {
			wxlogin() {
				uni.getUserProfile({
					desc: '登录后同步数据',
					that: this,
					success: (ures) => {
						console.log(ures);
						wx.login({
							success: (lres) => {
								const userData = {
									username1: ures.userInfo.nickName,
									url: ures.userInfo.avatarUrl,
								};
								uni.setStorage({
									key: 'userData',
									data: userData,
									success() {
										console
											.log(
												userData
											);
										uni.switchTab({
											url: '../user/user',
										});
									},
								});

								let params = {
									code: lres.code
								}

							}
						})
					}
				})
			}
		},
	};
</script>

<style lang="scss" scoped>
	.my-container {
		display: flex;
		flex-direction: column;
		align-items: center;
		padding-top: 25%;

		.avatar-img {
			width: 78px;
			height: 78px;
		}

		.login-desc {
			color: #999;
			font-size: 14px;
			margin-top: 16px;
		}

		.login-btn {
			margin-top: 16px;
			width: 85%;
		}
	}
</style>